



<template>
<view>
    <view>
        <u-upload @on-success="handleSuccess" :show-upload-list="false" :custom-btn="true" ref="uUpload" :header="header" :action="action" :auto-upload="true" >
            <view slot="addBtn" class="slot-btn" hover-class="slot-btn__hover" hover-stay-time="150">
			
              <view v-if="type!='custom'">
              <u-avatar size="160" v-if="imgUrl" :src="imgUrl"></u-avatar>
                <view class="upload-preview" v-else>
                    <u-icon  name="photo" size="90" color="#c0c4cc"></u-icon>
                    
                </view>
              </view>
              <view v-else>
                <slot></slot>
              </view>


          	</view>


        </u-upload>
    </view>
</view>

</template>
    
  <script>
  let s;
    export default {
        emits:['getImg'],
      props: {
        type:{
          type:String,
            default:'',
        },
        imgUrl:{
          type:String,
            default:'',
        },
       
      },
      data() {
        return {
            header:{
                'wid': uni.getStorageSync('wid'),
                'UserToken':  uni.getStorageSync('h5Token'),
            },
            action: uni.getStorageSync('host')+'/gptcms/api/uploadfile',
			filesArr: []
        }
      },
      async created(){
        
      },
      methods: {
        handleSuccess(val){
            // console.log(val,'cccccc')
            this.$emit('getImg',val.data.url)
        }
      }
    }
  </script>
  <style lang="scss" scoped>
.upload-preview{
    width: 80px;
    height: 80px;
    border-radius: 50%;
    background:rgba(#151520, 0.8);
    border: 2px solid #151520;
    display: flex;
    align-items: center;
    justify-content: center;
}
</style>
    